clear all
global system "linux"

if "${system}" == "linux" {
	*global code "/"
	global code "/"
	global s "/"
}

run "${code}${s}_set-path.do"

***** 4. Exogenous variables around the cutoff 
cd "${code}/tba_elig"
local flist1: dir "${Estimates}" files "harp-loanchar-*.gph"
local flist2: dir "${Estimates}" files "harp-loanchar-*.ster"
foreach f in `flist1' `flist2' {
	cap erase "${Estimates}/`f'"
}
local flist: dir "${log}" files "*"
foreach f of local flist {
	cap erase "${log}/`f'"
}

local cmd "sbatch -export=HOME,PATH,SHELL -a 1-16 HARP-checks-loanchar.sh" 
di "`cmd'"

local JobIdFile "${log}/job-id.csv"  
log using `JobIdFile', name("jobid") text replace
shell `cmd'
log close _all

do _sbatch-job "`JobIdFile'"


// combine figures
foreach Sample in 1 2 {
	local glist 
	foreach n of numlist 1/4 {
		local glist "`glist' ${Estimates}/harp-loanchar-DepVar`n'-Sample`Sample'.gph"
	}
	graph combine `glist'  
	graph export "${figure}/harp-loanchar-Sample`Sample'.pdf", replace
}

// Tables for prepayment and loan characteristicredit_score
qui do _create-tables-prepaid-loanchar

